<template>
  <div id="app">
    <router-view/>
    <van-tabbar v-model="active" active-color="green" @change="changeHland" class="testpadding" >
        <van-tabbar-item icon="wap-home">首页</van-tabbar-item>
        <van-tabbar-item icon="apps-o">热卖</van-tabbar-item>
        <van-tabbar-item icon="completed">发现</van-tabbar-item>
        <van-tabbar-item icon="cart-o" :info="this.shopCart">购物车</van-tabbar-item>
        <van-tabbar-item icon="circle">我</van-tabbar-item>
      </van-tabbar>
  </div>
</template>

<script>
import { getShopCartCount } from './servers/user.js'
export default {
  created () {
    this.$eventBus.$on('addToShopCartend',()=>{
     this.shopCart = getShopCartCount()
    }),
    this.$eventBus.$on('nanto',(link)=>{
      if(link=='usercent'){
        this.active=3
      }
    })
  },
   data() {
    return {
      active:0,
      shopCart:0,
    }
  },
  methods: {
    changeHland(){
      switch(this.active){
        case 0 :
        
        this.$router.push({
          name:'home',
        })
        break;
        case 1 :
        this.$router.push({
          name:'rou',
        })
        break;
        case 2 :
        this.$router.push({
          name:'find',
        })
        break;
        case 3 :
        this.$router.push({
          name:'car',
        })
        break;
        case 4 :
        this.$router.push({
          name:'UserCenterCG',
        })
        break;
      }
    }
  }
}
</script>

<style scoped>
.testpadding{
  margin-top:1.875rem
}

</style>
